﻿<local:BasePage
    x:Class="TheVerge.Phone.Pages.PodcastPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TheVerge.Phone.Pages"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True">
    <local:BasePage.Resources>
        <local:TotalSecondsFriendStringConverter x:Key="positionConv" />
        <local:TotalSecondsFriendStringConverter x:Key="remainingConv" />
    </local:BasePage.Resources>
    <Grid Background="{StaticResource PhoneBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Border Background="Black">
            <Image Height="44" Stretch="Uniform" Source="/Images/TheVerge_DarkBackground.png" />
        </Border>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="0" DataContext="{Binding Podcast}">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <phone:WebBrowser x:Name="webBrowser" IsScriptEnabled="True" Margin="12,0,12,5" ScriptNotify="theBrowser_ScriptNotify"
                          Background="{StaticResource PhoneBackgroundBrush}" />

            <Grid Grid.Row="1" Background="{StaticResource PhoneChromeBrush}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="48" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Slider x:Name="positionIndicator" Grid.ColumnSpan="5" Grid.Row="1" Margin="12,0" 
                        Foreground="{StaticResource PhoneAccentBrush}"
                        Background="{StaticResource PhoneContrastForegroundBrush}"
                        MouseLeftButtonDown="PositionIndicator_MouseLeftButtonDown"
                        ManipulationStarted="PositionIndicator_ManipulationStarted"
                        ManipulationCompleted="PositionIndicator_ManipulationCompleted" />

                <TextBlock x:Name="textPosition" Text="{Binding ElementName=positionIndicator, Path=Value, Converter={StaticResource positionConv}}" VerticalAlignment="Center" Margin="12,0,0,0" />

                <Button Style="{StaticResource mediaButton}" Grid.Column="1" x:Name="btnRW" ContentTemplate="{StaticResource dtRW}" Click="Rewind_Click" />
                <Button Style="{StaticResource mediaButton}" Grid.Column="2" x:Name="btnPP" ContentTemplate="{StaticResource dtPlay}" Click="Play_Click" />
                <Button Style="{StaticResource mediaButton}" Grid.Column="3" x:Name="btnFF" ContentTemplate="{StaticResource dtFF}" Click="Forward_Click" />

                <TextBlock x:Name="textRemaining" Text="{Binding ElementName=positionIndicator, Path=Value, 
                    Converter={StaticResource remainingConv}}" VerticalAlignment="Center" Margin="0" Grid.Column="4" />
            </Grid>
        </Grid>
    </Grid>
</local:BasePage>